package gestionePacchettiViaggio;

import java.util.ArrayList;

import gestione.mgrPacchettoviaggio.AlbergoMgr;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

import dataTransferOblect.AlbergoDTO;



@ManagedBean(name="gestioneAlbergo")
@RequestScoped
public class GestioneAlbergo {
	
	@EJB
	private AlbergoMgr albergoMgr;

	private AlbergoDTO albergo;
	
	private ArrayList<AlbergoDTO> albergoDTOs;
	
	public GestioneAlbergo(){
		albergo = new AlbergoDTO();
	}

	public AlbergoDTO getAlbergo() {
		return albergo;
	}
	
	public ArrayList<AlbergoDTO> getAllAlberghi(){
		albergoDTOs = new ArrayList<AlbergoDTO>();
		albergoDTOs.addAll(albergoMgr.getAlberghi());
		return albergoDTOs;
	}
	
	public ArrayList<String> getAllNomeAlberghi(){
		ArrayList<String >nomiAlberghi = new ArrayList<String>();
		for (int i=0;i<albergoMgr.getAlberghi().size(); i++){
		nomiAlberghi.add(albergoMgr.getAlberghi().get(i).getNomeAlbergo());
		}
		return nomiAlberghi;
	}

	public void setAlbergo(AlbergoDTO albergo) {
		this.albergo = albergo;
	}
	
	public ArrayList<AlbergoDTO> getAlbergoDTOs() {
		return albergoDTOs;
	}

	public void setAlbergoDTOs(ArrayList<AlbergoDTO> albergoDTOs) {
		this.albergoDTOs = albergoDTOs;
	}

	public String aggiungiAlbergo(){
		albergoMgr.aggiungiAlbergo(albergo);
		return "index.xhtml";
	}

}
